<?php
define('STATIC_URL', '');
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'YiiBook.com',

	'theme'=> 'classic',
	'language'=>'zh_cn',
		
	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool
		
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>false,
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
		),
		
		'book'=>array(
			'class'=>'application.modules.book.BookModule'
		),
			
		'admin'=>array(
			'class'=>'application.modules.admin.AdminModule'
		)
	),

	// application components
	'components'=>array(
		'clientScript'=>array(
			'class'=>'application.components.ClientScript',
		),
			
		'cache'=>array(
			'class'=>YII_DEBUG ?'CFileCache' : 'CFileCache',
			/*'servers' => array(
				array('host' => 'localhost', 'port' => 11211, 'weight' => 100),
			)*/
		),
			
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),
		// uncomment the following to enable URLs in path-format

		'urlManager'=>array(
			'urlFormat'=>'path',
			'showScriptName'=>false,
			'rules'=>array(
				
				//兼容之前的url
				'<bookFlag:agile_web_application_development_with_yii1.1_and_php5>/<chapterFlag:[a-zA-z0-9_\-\.]+>'=>array(
						'site/goto',
						'caseSensitive'=>false,
				),
				'<bookFlag:agile_web_application_development_with_yii1.1_and_php5>'=>array(
						'site/goto',
						'caseSensitive'=>false,
						'matchValue'=>true,
				),
				
				'/' => 'site/index',

				'book/<lang:en>/<bookFlag:[a-zA-z0-9_\.]+>'=> 'book/default/index',
				'book/<lang:en>/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>' => 'book/default/chapter',

				//新的url规则
				'book/hits' => 'book/default/hits',
				'book/<bookFlag:[a-zA-z0-9_\.]+>'=> 'book/default/index',
				'book/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>' => 'book/default/chapter',
				'book/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>/mb' => 'book/default/showMb',
				'book/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>/comments' => 'book/comments/index',
				'book/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>/comments/counts' => 'book/comments/counts',
				'book/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>/comments/<sectionId:\d+>' => 'book/comments/section',		
				'book/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>/original/<sectionId:\d+>' => 'book/comments/original',

					
				//后台规则
				#'admin/login'=>'admin/account/login',
				#'admin'=>'admin/default/index',
				#'admin/book'=>'admin/book/index',
				#'admin/chapter/<bookFlag:[a-zA-z0-9_\.]+>'=>'admin/chapter/index',
				#'admin/section/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>'=>'admin/section/index',
				#'admin/section/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>/create'=>'admin/section/create',
				#'admin/section/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>/preview/<sectionId:\d+>'=>'admin/section/preview',
				#'admin/section/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>/update/<sectionId:\d+>'=>'admin/section/update',
				#'admin/section/<bookFlag:[a-zA-z0-9_\.]+>/<chapterFlag:[a-zA-z0-9_\-\.]+>/translate/<sectionId:\d+>'=>'admin/section/translate',

					
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),

		'db'=>array(
			'connectionString' => 'mysql:host=127.0.0.1;dbname=book',
			'schemaCachingDuration'=> YII_DEBUG ? 0: 3600,
			'emulatePrepare' => !YII_DEBUG,
			'enableParamLogging'=> !YII_DEBUG,
                        'username' => 'book',
                        'password' => '',
			'charset' => 'utf8',
			'tablePrefix'=>'book_'
		),

		'errorHandler'=>array(
			// use 'site/error' action to display errors
			'errorAction'=>'site/error',
		),

		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
					'levels'=>'trace, info, error, warning',
					'categories'=>'system.db.CDbCommand.*',
					'showInFireBug'=>true
				),
				*/
			),
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
		'adminEmail'=>'admin@yiibook.com',
		'metaKeywords'=>'Yiiframework\'s Books Yii框架图书',
		'metaDescription'=>'Yiiframework\'s Books Yii框架图书',
		'codeTypeDesc'=>false,	//显示代码类型说明
		'copyright' => 'Copyright 2011-2012.',	//版权信息
		'bookCacheId'=>array(
				'book'=>'book_{id}',
				'chapter'=>'chapter_{id}',
				'section'=>'section_{id}',
				'tableOfContents'=>'talbleofcontents_{id}',
				'chapter'=>'chapter_{id}',
				'expressNav'=>'express_nav_{id}',
				'commentsCounts'=>'comments_counts_{id}',
				'sectionComments'=>'section_comments_{id}',
				'original'=>'original_{id}',
				'comments'=>'comments_{id}'
		)
	),
);
